/**
 * \file kernel/color.h 
 */

#ifndef DODO_COLOR_H
#define DODO_COLOR_H

namespace dodo_plot
{

/**
 * RGB color, with alpha.
 * r(), g(), b(), a() returns 0.0 ~ 1.0
 * int_r(), ... etc returns 0 ~ 255
 */
class Color
{
public:
	
	Color() : r_(0.0), g_(0.0), b_(0.0), a_(0.0) { }
	Color(double red, double green, double blue, double alpha = 1.0)
		: r_(red * 255.0), g_(green * 255.0), b_(blue * 255.0), a_(alpha * 255.0) { }
	explicit Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255)
		: r_(red), g_(green), b_(blue), a_(alpha) { }
	explicit Color(int red, int green, int blue, int alpha = 255)
		: r_(red), g_(green), b_(blue), a_(alpha) { }
	
	double r() const { return r_ / 255.0; }
	double g() const { return g_ / 255.0; }
	double b() const { return b_ / 255.0; }
	double a() const { return a_ / 255.0; }
	int int_r() const { return r_; }
	int int_g() const { return g_; }
	int int_b() const { return b_; }
	int int_a() const { return a_; }

	bool operator== (const Color& c) const { return r_ == c.r_ && g_ == c.g_ && b_ == c.b_ && a_ == c.a_; }
	bool operator!= (const Color& c) const { return !(*this == c); }
private:
	unsigned char r_, g_, b_, a_;
};

/**
 * Namespace dodo_plot::color_name holds several common color names, 
 * including TRANPARENT
 * See http://oreilly.com/catalog/wdnut/excerpt/color_names.html
 */

namespace color_name
{
const Color TRANSPARENT		= Color(0, 0, 0, 0);
const Color BLACK		= Color(0, 0, 0);
const Color WHITE		= Color(255, 255, 255);
const Color RED			= Color(255, 0, 0);
const Color GREEN		= Color(0, 128, 0);
const Color BLUE		= Color(0, 0, 255);

const Color ALICEBLUE			= Color(240, 248, 255);
const Color DARKSLATEGRAY		= Color(47, 79, 79);
const Color LIGHTSALMON			= Color(255, 160, 122);
const Color PALEVIOLETRED		= Color(219, 112, 147);
const Color ANTIQUEWHITE		= Color(250, 235, 215);
const Color DARKTURQUOISE		= Color(0, 206, 209);
const Color LIGHTSEAGREEN		= Color(32, 178, 170);
const Color PAPAYAWHIP			= Color(255, 239, 213);
const Color AQUA			= Color(0, 255, 255);
const Color DARKVIOLET			= Color(148, 0, 211);
const Color LIGHTSKYBLUE		= Color(135, 206, 250);
const Color PEACHPUFF			= Color(255, 239, 213);
const Color AQUAMARINE			= Color(127, 255, 212);
const Color DEEPPINK			= Color(255, 20, 147);
const Color LIGHTSLATEGRAY		= Color(119, 136, 153);
const Color PERU			= Color(205, 133, 63);
const Color AZURE			= Color(240, 255, 255);
const Color DEEPSKYBLUE			= Color(0, 191, 255);
const Color LIGHTSTEELBLUE		= Color(176, 196, 222);
const Color PINK			= Color(255, 192, 203);
const Color BEIGE			= Color(245, 245, 220);
const Color DIMGRAY			= Color(105, 105, 105);
const Color LIGHTYELLOW			= Color(255, 255, 224);
const Color PLUM			= Color(221, 160, 221);
const Color BISQUE			= Color(255, 228, 196);
const Color DODGERBLUE			= Color(30, 144, 255);
const Color LIME			= Color(0, 255, 0);
const Color POWDERBLUE			= Color(176, 224, 230);
const Color FIREBRICK			= Color(178, 34, 34);
const Color LIMEGREEN			= Color(50, 205, 50);
const Color PURPLE			= Color(128, 0, 128);
const Color BLANCHEDALMOND		= Color(255, 255, 205);
const Color FLORALWHITE			= Color(255, 250, 240);
const Color LINEN			= Color(250, 240, 230);
const Color FORESTGREEN			= Color(34, 139, 34);
const Color MAGENTA			= Color(255, 0, 255);
const Color ROSYBROWN			= Color(188, 143, 143);
const Color BLUEVIOLET			= Color(138, 43, 226);
const Color FUCHSIA			= Color(255, 0, 255);
const Color MAROON			= Color(128, 0, 0);
const Color ROYALBLUE			= Color(65, 105, 225);
const Color BROWN			= Color(165, 42, 42);
const Color GAINSBORO			= Color(220, 220, 220);
const Color MEDIUMAQUAMARINE		= Color(102, 205, 170);
const Color SADDLEBROWN			= Color(139, 69, 19);
const Color BURLYWOOD			= Color(222, 184, 135);
const Color GHOSTWHITE			= Color(248, 248, 255);
const Color MEDIUMBLUE			= Color(0, 0, 205);
const Color SALMON			= Color(250, 128, 114);
const Color CADETBLUE			= Color(95, 158, 160);
const Color GOLD			= Color(255, 215, 0);
const Color MEDIUMORCHID		= Color(186, 85, 211);
const Color SANDYBROWN			= Color(244, 164, 96);
const Color CHARTREUSE			= Color(127, 255, 0);
const Color GOLDENROD			= Color(218, 165, 32);
const Color MEDIUMPURPLE		= Color(147, 112, 219);
const Color SEAGREEN			= Color(46, 139, 87);
const Color CHOCOLATE			= Color(210, 105, 30);
const Color GRAY			= Color(128, 128, 128);
const Color MEDIUMSEAGREEN		= Color(60, 179, 113);
const Color SEASHELL			= Color(255, 245, 238);
const Color CORAL			= Color(255, 127, 80);
const Color MEDIUMSLATEBLUE		= Color(123, 104, 238);
const Color SIENNA			= Color(160, 82, 45);
const Color CORNFLOWERBLUE		= Color(100, 149, 237);
const Color GREENYELLOW			= Color(173, 255, 47);
const Color MEDIUMSPRINGGREEN		= Color(0, 250, 154);
const Color SILVER			= Color(192, 192, 192);
const Color CORNSILK			= Color(255, 248, 220);
const Color HONEYDEW			= Color(240, 255, 240);
const Color MEDIUMTURQUOISE		= Color(72, 209, 204);
const Color SKYBLUE			= Color(135, 206, 235);
const Color CRIMSON			= Color(220, 20, 60);
const Color HOTPINK			= Color(255, 105, 180);
const Color MEDIUMVIOLETRED		= Color(199, 21, 133);
const Color SLATEBLUE			= Color(106, 90, 205);
const Color CYAN			= Color(0, 255, 255);
const Color INDIANRED			= Color(205, 92, 92);
const Color MIDNIGHTBLUE		= Color(25, 25, 112);
const Color SLATEGRAY			= Color(112, 128, 144);
const Color DARKBLUE			= Color(0, 0, 139);
const Color INDIGO			= Color(75, 0, 130);
const Color MINTCREAM			= Color(245, 255, 250);
const Color SNOW			= Color(255, 250, 250);
const Color DARKCYAN			= Color(0, 139, 139);
const Color IVORY			= Color(255, 240, 240);
const Color MISTYROSE			= Color(255, 228, 225);
const Color SPRINGGREEN			= Color(0, 255, 127);
const Color DARKGOLDENROD		= Color(184, 134, 11);
const Color KHAKI			= Color(240, 230, 140);
const Color MOCCASIN			= Color(255, 228, 181);
const Color STEELBLUE			= Color(70, 130, 180);
const Color DARKGRAY			= Color(169, 169, 169);
const Color LAVENDER			= Color(230, 230, 250);
const Color NAVAJOWHITE			= Color(255, 222, 173);
const Color TAN				= Color(210, 180, 140);
const Color DARKGREEN			= Color(0, 100, 0);
const Color LAVENDERBLUSH		= Color(255, 240, 245);
const Color NAVY			= Color(0, 0, 128);
const Color TEAL			= Color(0, 128, 128);
const Color DARKKHAKI			= Color(189, 183, 107);
const Color LAWNGREEN			= Color(124, 252, 0);
const Color OLDLACE			= Color(253, 245, 230);
const Color THISTLE			= Color(216, 191, 216);
const Color DARKMAGENTA			= Color(139, 0, 139);
const Color LEMONCHIFFON		= Color(255, 250, 205);
const Color OLIVE			= Color(128, 128, 0);
const Color TOMATO			= Color(253, 99, 71);
const Color DARKOLIVEGREEN		= Color(85, 107, 47);
const Color LIGHTBLUE			= Color(173, 216, 230);
const Color OLIVEDRAB			= Color(107, 142, 35);
const Color TURQUOISE			= Color(64, 224, 208);
const Color DARKORANGE			= Color(255, 140, 0);
const Color LIGHTCORAL			= Color(240, 128, 128);
const Color ORANGE			= Color(255, 165, 0);
const Color VIOLET			= Color(238, 130, 238);
const Color DARKORCHID			= Color(153, 50, 204);
const Color LIGHTCYAN			= Color(224, 255, 255);
const Color ORANGERED			= Color(255, 69, 0);
const Color WHEAT			= Color(245, 222, 179);
const Color DARKRED			= Color(139, 0, 0);
const Color LIGHTGOLDENRODYELLOW	= Color(250, 250, 210);
const Color ORCHID			= Color(218, 112, 214);
const Color DARKSALMON			= Color(233, 150, 122);
const Color LIGHTGREEN			= Color(144, 238, 144);
const Color PALEGOLDENROD		= Color(238, 232, 170);
const Color WHITESMOKE			= Color(245, 245, 245);
const Color DARKSEAGREEN		= Color(143, 188, 143);
const Color LIGHTGREY			= Color(211, 211, 211);
const Color PALEGREEN			= Color(152, 251, 152);
const Color YELLOW			= Color(255, 255, 0);
const Color DARKSLATEBLUE		= Color(72, 61, 139);
const Color LIGHTPINK			= Color(255, 182, 193);
const Color PALETURQUOISE		= Color(175, 238, 238);
const Color YELLOWGREEN			= Color(154, 205, 50);
} // namespace color_name

} // namespace dodo_plot

#endif //DODO_COLOR_H

